const Mock = require('mockjs')
let { cartList } = Mock.mock({
  "cartList|4": [{
    "id": "@id",
    "image": "@image(120x80, @color)",
    "title": "@ctitle",
    "desc": "@cword(10, 20)",
    "price|0.1-1": 1,
    "count|1-5": 1,
    "check": true
  }]
})
module.exports = app => {
  app.get('/api/cart/list', (req, res) => {
    res.send({
      code: 200,
      data: cartList
    })
  })
  app.delete('/api/cart/list', (req, res) => {
    const { id } = req.query;
    cartList = cartList.filter(v => v.id !== id);
    res.send({
      code: 200,
      message: '删除成功'
    })
  })
}